package com.xlh.virtualization.dao.helper;

import com.xlh.virtualization.dao.ContainerDeleteConfigMapper;
import com.xlh.virtualization.domain.ContainerDeleteConfig;
import com.xlh.virtualization.domain.example.ContainerDeleteConfigExample;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author cheer
 */
@Repository
public class ContainerDeleterConfigMapperHelper {

    @Autowired
    private ContainerDeleteConfigMapper containerDeleteConfigMapper;

    /**
     * 查询虚拟化配置
     *
     * @return 虚拟化配置信息
     */
    public ContainerDeleteConfig getConfig(Long courseId) {
        ContainerDeleteConfigExample example = new ContainerDeleteConfigExample();
        example.or().andCourseIdEqualTo(courseId)
                .andDeletedEqualTo(false);
        List<ContainerDeleteConfig> containerDeleteConfigs = containerDeleteConfigMapper.selectByExample(example);
        if (CollectionUtils.isNotEmpty(containerDeleteConfigs)) {
            return containerDeleteConfigs.get(0);
        }
        return null;
    }
}
